/**
 * Created with IntelliJ IDEA.
 * Description:
 * Date: 2023-05-30
 * Time: 21:15
 */
public class Test2 {
    public String name ="lkx";
    public String pssword = "123456";
    public  void login(String name,String pssword){
        if(!this.name.equals(name)){
            System.out.println("用户名错误！");
            throw new UserNameException("你的用户名错了");
        }
        if(!this.pssword.equals(pssword)) {
            System.out.println("密码错误！");
            throw new PassWordException("你的密码错了");
        }
    }

/*    public  void login1(String name,String pssword){
        if(!this.name.equals(name)){
            System.out.println("用户名错误！");
            throw new UserNameException();
        }
        if(!this.pssword.equals(pssword)){
            System.out.println("密码错误！");
        }
    }*/

    public static void main(String[] args) {
        Test2 test2 = new Test2();
        try{
            test2.login("lk","12345");
        }catch (UserNameException e){
            e.printStackTrace();
            System.out.println("用户名异常！");
        }catch (PassWordException passWordException){
            passWordException.printStackTrace();
            System.out.println("密码异常！");
        }finally {

        }
    }
}
